package com.trainoo.repository;

import com.trainoo.domain.Chapter;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

/**
 * Created by zhoutao on 2018/6/28 17:17
 */

public interface ChapterRepository extends JpaRepository<Chapter, Integer> {

    /**
     * Query 里面 Chapter 是实体类， 字段用实体类里面的属性名，而不是表的字段名
     */
    @Query("select c from Chapter c where c.titleNum=:num")
    Chapter findByNum(@Param("num") Integer num);

    @Query("select c.title from Chapter c where c.isPush=1")
    List<String> findAllPushedTitle();
}
